Add feature spec

This commit is contained in:
uu59 2014-05-13 16:45:59 +09:00
parent 136d4da7b6
commit fc044bd719
4 changed files with 43 additions and 1 deletions

View File

@ -10,4 +10,5 @@ group :development, :test do
gem "rspec-rails", "~> 2.0" gem "rspec-rails", "~> 2.0"
gem "factory_girl_rails" gem "factory_girl_rails"
gem "database_cleaner", "~> 1.2.0" gem "database_cleaner", "~> 1.2.0"
gem "capybara", "~> 2.2.1"
end end

View File

@ -47,6 +47,12 @@ GEM
arel (5.0.1.20140414130214) arel (5.0.1.20140414130214)
bcrypt (3.1.7) bcrypt (3.1.7)
builder (3.2.2) 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) coderay (1.1.0)
coffee-rails (4.0.1) coffee-rails (4.0.1)
coffee-script (>= 2.2.0) coffee-script (>= 2.2.0)
@ -188,12 +194,15 @@ GEM
unf_ext unf_ext
unf_ext (0.0.6) unf_ext (0.0.6)
webrobots (0.1.1) webrobots (0.1.1)
xpath (2.0.0)
nokogiri (~> 1.3)
yajl-ruby (1.2.0) yajl-ruby (1.2.0)
PLATFORMS PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
capybara (~> 2.2.1)
database_cleaner (~> 1.2.0) database_cleaner (~> 1.2.0)
factory_girl_rails factory_girl_rails
fluentd-ui! fluentd-ui!

View File

@ -4,4 +4,5 @@
= f.text_field :name = f.text_field :name
= f.label :password = f.label :password
= f.text_field :password = f.text_field :password
= f.submit = submit_tag t("terms.sign_in")

View File

@ -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