spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.4 vs spec/rspec/matchers/matcher_spec.rb in rspec-expectations-2.0.0.beta.5
- old
+ new
@@ -284,39 +284,34 @@
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
+ def a_method_in_the_example
+ "method defined in the example"
+ end
+
+ it "can access methods in the running_example" do
Rspec::Matchers.define(:__access_running_example) do
match do |actual|
- actual == running_example
+ a_method_in_the_example == "method defined in the 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
+ it "raises NoMethodError for methods not in the running_example" do
+ Rspec::Matchers.define(:__raise_no_method_error) do
match do |actual|
- actual == running_example
+ a_method_not_in_the_example == "method defined in the example"
end
end
+
+ expect do
+ running_example.should __raise_no_method_error
+ end.to raise_error(/Rspec::Matchers::Matcher/)
end
-
- it "can access the running_example" do
- running_example.should access_running_example
- end
end
+
end
end
end