diff options
author | Louise Crow <louise.crow@gmail.com> | 2011-02-24 15:10:14 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2011-02-24 15:10:14 +0000 |
commit | 08a64f9e3139851fd65c7ba6969ee590b4afea6a (patch) | |
tree | 20c77e796002dfa95b2af3ba00ebd2f691c02fc7 /vendor/gems/rspec-1.3.1/features/example_groups | |
parent | 3757bb52c0aa86b779b00428d7ebe35b30cea1ee (diff) |
Adding rspec gem.
Diffstat (limited to 'vendor/gems/rspec-1.3.1/features/example_groups')
4 files changed, 161 insertions, 0 deletions
diff --git a/vendor/gems/rspec-1.3.1/features/example_groups/define_example_attribute.feature b/vendor/gems/rspec-1.3.1/features/example_groups/define_example_attribute.feature new file mode 100644 index 000000000..9fc72ac64 --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/example_groups/define_example_attribute.feature @@ -0,0 +1,41 @@ +Feature: Define example attribute + + In order to streamline process + As an RSpec user + I want to easily define helper methods that act as a variable assignment + + It is fairly common to start with a local variable in one example, use the same + local variable in the next, and then extract the declaration of that variable + to before(:each). This requires converting the locals to instance variables. + + This feature streamlines the process by defining a helper method so you can extract + the duplication without having to change other references to the same variables + to @instance_variables. + + Scenario: + Given a file named "counter_spec.rb" with: + """ + require 'spec/autorun' + + class Counter + def initialize + @count = 0 + end + def count + @count += 1 + end + end + + describe Counter do + let(:counter) { Counter.new } + it "returns 1 the first time" do + counter.count.should == 1 + end + it "returns 2 the second time because the counter itself is cached by the 'assign' method" do + counter.count + counter.count.should == 2 + end + end + """ + When I run "spec counter_spec.rb" + Then the stdout should include "2 examples, 0 failures" diff --git a/vendor/gems/rspec-1.3.1/features/example_groups/example_group_with_should_methods.feature b/vendor/gems/rspec-1.3.1/features/example_groups/example_group_with_should_methods.feature new file mode 100644 index 000000000..b5f76bf8a --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/example_groups/example_group_with_should_methods.feature @@ -0,0 +1,29 @@ +Feature: Spec::ExampleGroup with should methods + + As an RSpec adopter accustomed to classes and methods + I want to use should_* methods in an ExampleGroup + So that I use RSpec with classes and methods that look more like RSpec examples + + Scenario Outline: Example Group class with should methods + Given a file named "example_group_with_should_methods.rb" with: + """ + require 'spec/autorun' + + class MySpec < Spec::ExampleGroup + def should_pass_with_should + 1.should == 1 + end + + def should_fail_with_should + 1.should == 2 + end + end + """ + When I run "<Command> example_group_with_should_methods.rb" + Then the exit code should be 256 + And the stdout should include "2 examples, 1 failure" + + Scenarios: Run with ruby and spec + | Command | + | ruby | + | spec | diff --git a/vendor/gems/rspec-1.3.1/features/example_groups/implicit_docstrings.feature b/vendor/gems/rspec-1.3.1/features/example_groups/implicit_docstrings.feature new file mode 100644 index 000000000..b83a3470c --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/example_groups/implicit_docstrings.feature @@ -0,0 +1,59 @@ +Feature: implicit docstrings + + As an RSpec user + I want examples to generate their own names + So that I can reduce duplication between example names and example code + + Scenario Outline: run passing examples + Given a file named "implicit_docstrings_example.rb" with: + """ + require 'spec/autorun' + describe "Examples with no docstrings generate their own:" do + + specify { 3.should be < 5 } + + specify { ["a"].should include("a") } + + specify { [1,2,3].should respond_to(:size) } + + end + """ + + When I run "<Command> implicit_docstrings_example.rb -fs" + + Then the stdout should include /should be < 5/ + And the stdout should include /should include "a"/ + And the stdout should include /should respond to #size/ + + Scenarios: Run with ruby and spec + | Command | + | ruby | + | spec | + + Scenario Outline: run failing examples + Given a file named "failing_implicit_docstrings_example.rb" with: + """ + require 'spec/autorun' + describe "Failing examples with no descriptions" do + + # description is auto-generated as "should equal(5)" based on the last #should + it do + 3.should equal(2) + 5.should equal(5) + end + + it { 3.should be > 5 } + + it { ["a"].should include("b") } + + it { [1,2,3].should_not respond_to(:size) } + + end + """ + + When I run "<Command> failing_implicit_docstrings_example.rb -fs" + + Then the stdout should include /should equal 2/ + And the stdout should include /should be > 5/ + And the stdout should include /should include "b"/ + And the stdout should include /should not respond to #size/ diff --git a/vendor/gems/rspec-1.3.1/features/example_groups/nested_groups.feature b/vendor/gems/rspec-1.3.1/features/example_groups/nested_groups.feature new file mode 100644 index 000000000..6d8c7aadf --- /dev/null +++ b/vendor/gems/rspec-1.3.1/features/example_groups/nested_groups.feature @@ -0,0 +1,32 @@ +Feature: Nested example groups + + As an RSpec user + I want to nest examples groups + So that I can better organize my examples + + Scenario Outline: Nested example groups + Given a file named "nested_example_groups.rb" with: + """ + require 'spec/autorun' + + describe "Some Object" do + describe "with some more context" do + it "should do this" do + true.should be_true + end + end + describe "with some other context" do + it "should do that" do + false.should be_false + end + end + end + """ + When I run "<Command> nested_example_groups.rb -fs" + Then the stdout should include /Some Object with some more context/ + And the stdout should include /Some Object with some other context/ + + Scenarios: Run with ruby and spec + | Command | + | ruby | + | spec | |