Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added match_script Matcher for RSspec; found bug in NudgeBlueprint#wr…

…ap_block
  • Loading branch information...
commit 8154b8a628c3d480f99fc1d0ad8c75a1fba266a7 1 parent e46c395
Bill Tozier Vaguery authored
Showing with 30 additions and 2 deletions.
  1. +11 −1 spec/built-in/machines/wrap_block_spec.rb
  2. +19 −1 spec/spec_helper.rb
12 spec/built-in/machines/wrap_block_spec.rb
View
@@ -13,7 +13,7 @@
before(:each) do
Factory.stub!(:save_answers)
@spec_machine = WrapBlock.new(:here)
- @dummy_answer = Answer.new(NudgeBlueprint.new("block{ do foo do bar}"))
+ @dummy_answer = Answer.new(NudgeBlueprint.new("block{ do foo do bar do baz}"))
end
@@ -52,4 +52,14 @@
output_hash.values[0].should include(@dummy_answer)
output_hash.values[1].should_not include(@dummy_answer)
end
+
+
+ it "should always modify the blueprints of the answers it makes" do
+ pending "broken in NudgeBlueprint#wrap_block"
+ @spec_machine.create 100
+ @spec_machine.should_receive(:answers).
+ at_least(1).times.and_return([@dummy_answer])
+ output_hash = @spec_machine.process_answers
+ output_hash.values[1].each {|answer| answer.blueprint.should_not match_script(@dummy_answer.blueprint)}
+ end
end
20 spec/spec_helper.rb
View
@@ -1,2 +1,20 @@
require File.expand_path("../answer_factory", File.dirname(__FILE__))
-require 'rspec'
+require 'rspec'
+
+RSpec::Matchers.define :match_script do |other_script|
+ match do |script|
+ NudgePoint.from(script).to_script == NudgePoint.from(other_script).to_script
+ end
+
+ failure_message_for_should do |script|
+ "expected #{script} to match #{other_script}"
+ end
+
+ failure_message_for_should_not do |script|
+ "expected #{script} to differ from #{other_script}"
+ end
+
+ description do
+ "expected a Nudge script matching #{other_script}"
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.