Merge pull request #840 from danryan/alias_given_to_let
alias given and given! to let and let!
This commit is contained in:
commit
e73628d558
13
README.md
13
README.md
|
@ -138,11 +138,22 @@ feature "Signing up" do
|
|||
end
|
||||
click_link 'Sign in'
|
||||
end
|
||||
|
||||
given(:other_user) { User.make(:email => 'other@example.com', :password => 'rous') }
|
||||
|
||||
scenario "Signing in as another user" do
|
||||
within("#session") do
|
||||
fill_in 'Login', :with => other_user.email
|
||||
fill_in 'Password', :with => other_user.password
|
||||
end
|
||||
click_link 'Sign in'
|
||||
end
|
||||
|
||||
end
|
||||
```
|
||||
|
||||
`feature` is in fact just an alias for `describe ..., :type => :request`,
|
||||
`background` is an alias for `before`, and `scenario` for `it`.
|
||||
`background` is an alias for `before`, `scenario` for `it`, and `given`/`given!` aliases for `let`/`let!`, respectively.
|
||||
|
||||
## Using Capybara with Test::Unit
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ module Capybara
|
|||
base.instance_eval do
|
||||
alias :background :before
|
||||
alias :scenario :it
|
||||
alias :given :let
|
||||
alias :given! :let!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,20 @@ feature "Capybara's feature DSL" do
|
|||
end
|
||||
end
|
||||
|
||||
feature "given and given! aliases to let and let!" do
|
||||
given(:value) { :available }
|
||||
given!(:value_in_background) { :available }
|
||||
|
||||
background do
|
||||
value_in_background.should be(:available)
|
||||
end
|
||||
|
||||
scenario "given and given! work as intended" do
|
||||
value.should be(:available)
|
||||
value_in_background.should be(:available)
|
||||
end
|
||||
end
|
||||
|
||||
feature "Capybara's feature DSL with driver", :driver => :culerity do
|
||||
scenario "switches driver" do
|
||||
Capybara.current_driver.should == :culerity
|
||||
|
|
Loading…
Reference in New Issue