mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-21 09:40:13 +01:00
Added Rspec and Webrat plugins and started porting Selenium on Rails tests to Rspec Plain Text Stories driving Webrat driving Selenium.
This commit is contained in:
parent
0600756bbf
commit
0f7d6f7a1d
602 changed files with 47788 additions and 29 deletions
54
vendor/plugins/rspec/examples/pure/custom_expectation_matchers.rb
vendored
Normal file
54
vendor/plugins/rspec/examples/pure/custom_expectation_matchers.rb
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
module AnimalSpecHelper
|
||||
class Eat
|
||||
def initialize(food)
|
||||
@food = food
|
||||
end
|
||||
|
||||
def matches?(animal)
|
||||
@animal = animal
|
||||
@animal.eats?(@food)
|
||||
end
|
||||
|
||||
def failure_message
|
||||
"expected #{@animal} to eat #{@food}, but it does not"
|
||||
end
|
||||
|
||||
def negative_failure_message
|
||||
"expected #{@animal} not to eat #{@food}, but it does"
|
||||
end
|
||||
end
|
||||
|
||||
def eat(food)
|
||||
Eat.new(food)
|
||||
end
|
||||
end
|
||||
|
||||
module Animals
|
||||
class Animal
|
||||
def eats?(food)
|
||||
return foods_i_eat.include?(food)
|
||||
end
|
||||
end
|
||||
|
||||
class Mouse < Animal
|
||||
def foods_i_eat
|
||||
[:cheese]
|
||||
end
|
||||
end
|
||||
|
||||
describe Mouse do
|
||||
include AnimalSpecHelper
|
||||
before(:each) do
|
||||
@mouse = Animals::Mouse.new
|
||||
end
|
||||
|
||||
it "should eat cheese" do
|
||||
@mouse.should eat(:cheese)
|
||||
end
|
||||
|
||||
it "should not eat cat" do
|
||||
@mouse.should_not eat(:cat)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue