1 require File.dirname(__FILE__) + '/../spec_helper'
2 require 'mspec/matchers/base'
3 require 'mspec/runner/mspec'
4 require 'mspec/mocks/mock'
5 require 'mspec/runner/example'
7 describe ExampleState do
8 it "is initialized with the ContextState, #it string, and #it block" do
10 context = ContextState.new ""
11 ExampleState.new(context, "does", prc).should be_kind_of(ExampleState)
15 describe ExampleState, "#describe" do
17 @context = ContextState.new Object, "#to_s"
18 @state = ExampleState.new @context, "it"
21 it "returns the ContextState#description" do
22 @state.describe.should == @context.description
26 describe ExampleState, "#it" do
28 @state = ExampleState.new ContextState.new("describe"), "it"
31 it "returns the argument to the #it block" do
32 @state.it.should == "it"
36 describe ExampleState, "#context=" do
38 @state = ExampleState.new ContextState.new("describe"), "it"
39 @context = ContextState.new "New#context"
42 it "sets the containing ContextState" do
43 @state.context = @context
44 @state.context.should == @context
47 it "resets the description" do
48 @state.description.should == "describe it"
49 @state.context = @context
50 @state.description.should == "New#context it"
54 describe ExampleState, "#example" do
57 @state = ExampleState.new ContextState.new("describe"), "it", @proc
60 it "returns the #it block" do
61 @state.example.should == @proc
65 describe ExampleState, "#filtered?" do
67 MSpec.store :include, nil
68 MSpec.store :exclude, nil
70 @state = ExampleState.new ContextState.new("describe"), "it"
71 @filter = mock("filter")
74 it "returns false if MSpec include filters list is empty" do
75 @state.filtered?.should == false
78 it "returns false if MSpec include filters match this spec" do
79 @filter.should_receive(:===).and_return(true)
80 MSpec.register :include, @filter
81 @state.filtered?.should == false
84 it "returns true if MSpec include filters do not match this spec" do
85 @filter.should_receive(:===).and_return(false)
86 MSpec.register :include, @filter
87 @state.filtered?.should == true
90 it "returns false if MSpec exclude filters list is empty" do
91 @state.filtered?.should == false
94 it "returns false if MSpec exclude filters do not match this spec" do
95 @filter.should_receive(:===).and_return(false)
96 MSpec.register :exclude, @filter
97 @state.filtered?.should == false
100 it "returns true if MSpec exclude filters match this spec" do
101 @filter.should_receive(:===).and_return(true)
102 MSpec.register :exclude, @filter
103 @state.filtered?.should == true
106 it "returns true if MSpec include and exclude filters match this spec" do
107 @filter.should_receive(:===).twice.and_return(true)
108 MSpec.register :include, @filter
109 MSpec.register :exclude, @filter
110 @state.filtered?.should == true