spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.3 vs spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.4
- old
+ new
@@ -282,8 +282,41 @@
end
matcher.expecting('value').matches?('value').should be_true
matcher.expecting('value').matches?('other value').should be_false
end
+
+ context "defined using the dsl" do
+ it "can access the running_example" do
+ Rspec::Matchers.define(:__access_running_example) do
+ match do |actual|
+ actual == running_example
+ end
+ end
+ running_example.should __access_running_example
+ end
+ end
+
+ context "defined using #new" do
+ it "can access the running_example" do
+ @matcher = Rspec::Matchers::Matcher.new(:something) {}
+ @matcher.send(:running_example).should eq(running_example)
+ end
+ end
+
+ context "wrapped in a method" do
+
+ def access_running_example
+ Matcher.new(:access_running_example) do
+ match do |actual|
+ actual == running_example
+ end
+ end
+ end
+
+ it "can access the running_example" do
+ running_example.should access_running_example
+ end
+ end
end
end
end