spec/unit/sucker/stub_spec.rb in sucker-0.5.0 vs spec/unit/sucker/stub_spec.rb in sucker-0.6.0

- old
+ new

@@ -37,8 +37,39 @@ it "mocks the request if fixture is available" do File.open(@worker.fixture, "w") { |f| f.write "bar" } @worker.get.body.should eql "bar" end + + context "defines:" do + context "#fixture" do + it "ignores odd numbers" do + @worker << { "Foo" => "13579" } + @worker.fixture.should_not match /[^\/]*[13579][^\/]*xml$/ + end + + it "does not ignore odd numbers" do + @worker << { "Foo" => "24680" } + (0..8).step(2) do |odd_no| + @worker.fixture.should match Regexp.new(odd_no.to_s) + end + end + + it "ignores vowels" do + @worker << { "Foo" => "aeiou" } + @worker.fixture.should_not match /[^\/]*[aeiou][^\/]*xml$/ + end + + it "does not ignore consonants" do + @worker << { "Foo" => ("a".."z").to_a.join } + @worker.fixture.should include(("a".."z").to_a.join.gsub(/[aeiou]/, "")) + end + + it "ignores non-alphanumeric characters" do + @worker << { "Foo" => ";+*&!~" } + @worker.fixture.should_not match /[;+*&!~]/ + end + end + end end end end