Permalink
Browse files

alias given and given! to let and let!

  • Loading branch information...
1 parent 5a9a242 commit b8768d8398c6eb8b095fbf0ba6e3421d5e51dcf7 @danryan danryan committed Oct 3, 2012
Showing with 28 additions and 1 deletion.
  1. +12 −1 README.md
  2. +2 −0 lib/capybara/rspec/features.rb
  3. +14 −0 spec/rspec/features_spec.rb
View
@@ -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 @@ def self.included(base)
base.instance_eval do
alias :background :before
alias :scenario :it
+ alias :given :let
+ alias :given! :let!
end
end
end
@@ -36,6 +36,20 @@
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

0 comments on commit b8768d8

Please sign in to comment.