spec/spec/story/step_spec.rb in rspec-1.1.2 vs spec/spec/story/step_spec.rb in rspec-1.1.3
- old
+ new
@@ -56,15 +56,25 @@
it "should match a regexp with a match group" do
step = Step.new(/this (.*) text/) {}
step.matches?("this anything text").should be_true
end
+ it "should match a regexp with a named variable" do
+ step = Step.new(/this $variable text/) {}
+ step.matches?("this anything text").should be_true
+ end
+
it "should not match a non matching regexp" do
step = Step.new(/this (.*) text/) {}
step.matches?("other anything text").should be_false
end
+ it "should not match a non matching regexp with a named variable" do
+ step = Step.new(/this $variable text/) {}
+ step.matches?("other anything text").should be_false
+ end
+
it "should not get bogged down by parens in strings" do
step = Step.new("before () after") {}
step.matches?("before () after").should be_true
end
@@ -76,9 +86,21 @@
it "should match alteration as well as a variable" do
step = Step.new(/(he|she) is (.*)/) {}
step.matches?("he is cool").should be_true
step.parse_args("he is cool").should == ['he', 'cool']
+ end
+
+ it "should match alteration as well as a named variable" do
+ step = Step.new(/(he|she) is $adjective/) {}
+ step.matches?("he is cool").should be_true
+ step.parse_args("he is cool").should == ['he', 'cool']
+ end
+
+ it "should match alteration as well as a anonymous and named variable" do
+ step = Step.new(/(he|she) is (.*?) $adjective/) {}
+ step.matches?("he is very cool").should be_true
+ step.parse_args("he is very cool").should == ['he', 'very', 'cool']
end
end
describe Step do