diff --git a/Gemfile b/Gemfile index 1850ea6..0d547c2 100644 --- a/Gemfile +++ b/Gemfile @@ -10,4 +10,5 @@ group :development, :test do gem "rspec-rails", "~> 2.0" gem "factory_girl_rails" gem "database_cleaner", "~> 1.2.0" + gem "capybara", "~> 2.2.1" end diff --git a/Gemfile.lock b/Gemfile.lock index 28ab76a..8747ad6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,12 @@ GEM arel (5.0.1.20140414130214) bcrypt (3.1.7) builder (3.2.2) + capybara (2.2.1) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + xpath (~> 2.0) coderay (1.1.0) coffee-rails (4.0.1) coffee-script (>= 2.2.0) @@ -188,12 +194,15 @@ GEM unf_ext unf_ext (0.0.6) webrobots (0.1.1) + xpath (2.0.0) + nokogiri (~> 1.3) yajl-ruby (1.2.0) PLATFORMS ruby DEPENDENCIES + capybara (~> 2.2.1) database_cleaner (~> 1.2.0) factory_girl_rails fluentd-ui! diff --git a/app/views/sessions/new.html.haml b/app/views/sessions/new.html.haml index 5e1f88c..f1d3e69 100644 --- a/app/views/sessions/new.html.haml +++ b/app/views/sessions/new.html.haml @@ -4,4 +4,5 @@ = f.text_field :name = f.label :password = f.text_field :password - = f.submit + = submit_tag t("terms.sign_in") + diff --git a/spec/features/sign_in_spec.rb b/spec/features/sign_in_spec.rb new file mode 100644 index 0000000..31321b3 --- /dev/null +++ b/spec/features/sign_in_spec.rb @@ -0,0 +1,31 @@ +describe "the sign in process" do + let(:submit_label) { I18n.t("terms.sign_in") } + let(:exists_user) { FactoryGirl.create(:user) } + before do + visit '/sessions/new' + within("form") do + fill_in 'session_name', :with => user.name + fill_in 'session_password', :with => user.password + end + click_button submit_label + end + + context "sign in with exists user" do + let(:user) { exists_user } + it "login success, then redirect to root_path" do + current_path.should == root_path + end + end + + context "sign in with non-exists user" do + let(:user) { FactoryGirl.build(:user) } + + it "current location is not root_path" do + current_path.should_not == root_path + end + + it "display form for retry" do + page.body.should have_css('form') + end + end +end