rspec 1.1.11 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -0
- data/History.txt +55 -0
- data/Manifest.txt +102 -122
- data/README.txt +30 -12
- data/Rakefile +10 -10
- data/TODO.txt +10 -2
- data/{failing_examples → examples/failing}/README.txt +0 -0
- data/{failing_examples → examples/failing}/diffing_spec.rb +0 -0
- data/{failing_examples → examples/failing}/failing_autogenerated_docstrings_example.rb +0 -0
- data/{failing_examples/failure_in_teardown.rb → examples/failing/failure_in_after.rb} +1 -1
- data/{failing_examples/failure_in_setup.rb → examples/failing/failure_in_before.rb} +1 -1
- data/{failing_examples → examples/failing}/mocking_example.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_flexmock.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_mocha.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_rr.rb +0 -0
- data/{failing_examples → examples/failing}/partial_mock_example.rb +0 -0
- data/{failing_examples → examples/failing}/predicate_example.rb +5 -0
- data/{failing_examples → examples/failing}/raising_example.rb +0 -0
- data/{failing_examples → examples/failing}/spec_helper.rb +1 -1
- data/{failing_examples → examples/failing}/syntax_error_example.rb +0 -0
- data/{failing_examples → examples/failing}/team_spec.rb +0 -0
- data/{failing_examples → examples/failing}/timeout_behaviour.rb +0 -0
- data/examples/{pure → passing}/autogenerated_docstrings_example.rb +6 -0
- data/examples/{pure → passing}/before_and_after_example.rb +0 -0
- data/examples/{pure → passing}/behave_as_example.rb +0 -0
- data/examples/{pure → passing}/custom_expectation_matchers.rb +0 -0
- data/examples/{pure → passing}/custom_formatter.rb +1 -1
- data/examples/{pure → passing}/dynamic_spec.rb +2 -2
- data/examples/{pure → passing}/file_accessor.rb +0 -0
- data/examples/{pure → passing}/file_accessor_spec.rb +0 -0
- data/examples/{pure → passing}/greeter_spec.rb +0 -0
- data/examples/{pure → passing}/helper_method_example.rb +0 -0
- data/examples/{pure → passing}/io_processor.rb +0 -0
- data/examples/{pure → passing}/io_processor_spec.rb +0 -0
- data/examples/{pure → passing}/legacy_spec.rb +0 -0
- data/examples/{pure → passing}/mocking_example.rb +0 -0
- data/examples/{pure/multi_threaded_behaviour_runner.rb → passing/multi_threaded_example_group_runner.rb} +1 -3
- data/examples/{pure → passing}/nested_classes_example.rb +0 -0
- data/examples/{pure → passing}/partial_mock_example.rb +0 -0
- data/examples/{pure → passing}/pending_example.rb +0 -0
- data/examples/{pure → passing}/predicate_example.rb +0 -0
- data/examples/{pure → passing}/priority.txt +0 -0
- data/examples/{pure → passing}/shared_example_group_example.rb +0 -0
- data/examples/{pure → passing}/shared_stack_examples.rb +1 -3
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/examples/{pure → passing}/spec_helper.rb +0 -0
- data/examples/{pure → passing}/stack.rb +0 -0
- data/examples/{pure → passing}/stack_spec.rb +3 -2
- data/examples/{pure → passing}/stack_spec_with_nested_example_groups.rb +0 -0
- data/examples/{pure → passing}/stubbing_example.rb +0 -0
- data/examples/{pure → passing}/yielding_example.rb +0 -0
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +86 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +168 -0
- data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +5 -5
- data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
- data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +4 -4
- data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
- data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
- data/features/interop/test_but_not_test_unit.feature +14 -0
- data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
- data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
- data/features/step_definitions/running_rspec.rb +54 -0
- data/features/support/env.rb +26 -0
- data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
- data/{stories/resources → features/support}/helpers/story_helper.rb +1 -1
- data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rr.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +2 -2
- data/lib/autotest/rspec.rb +4 -3
- data/lib/spec.rb +2 -27
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/{extensions → dsl}/main.rb +10 -10
- data/lib/spec/example.rb +175 -1
- data/lib/spec/example/before_and_after_hooks.rb +30 -24
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +26 -9
- data/lib/spec/example/example_group_methods.rb +138 -113
- data/lib/spec/example/example_methods.rb +88 -25
- data/lib/spec/example/shared_example_group.rb +28 -21
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/expectations/handler.rb +16 -36
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/interop/test/unit/testresult.rb +1 -1
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
- data/lib/spec/matchers.rb +7 -28
- data/lib/spec/matchers/be.rb +103 -116
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +7 -25
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/match_array.rb +79 -0
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +39 -48
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +33 -8
- data/lib/spec/matchers/throw_symbol.rb +49 -17
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/mocks/argument_constraints.rb +77 -5
- data/lib/spec/mocks/message_expectation.rb +7 -7
- data/lib/spec/mocks/proxy.rb +14 -12
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner.rb +37 -162
- data/lib/spec/runner/backtrace_tweaker.rb +5 -3
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/{example → runner}/configuration.rb +46 -47
- data/lib/spec/runner/example_group_runner.rb +15 -4
- data/lib/spec/runner/formatter/base_text_formatter.rb +4 -3
- data/lib/spec/runner/formatter/html_formatter.rb +14 -11
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/heckle_runner.rb +58 -56
- data/lib/spec/runner/option_parser.rb +8 -4
- data/lib/spec/runner/options.rb +29 -14
- data/lib/spec/runner/reporter.rb +1 -1
- data/lib/spec/runner/spec_parser.rb +11 -9
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +4 -2
- data/{rake_tasks → resources/rake}/examples.rake +0 -0
- data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
- data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
- data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
- data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
- data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
- data/resources/spec/spec_with_flexmock.rb +19 -0
- data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
- data/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
- data/rspec.gemspec +16 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +2 -38
- data/spec/spec/dsl/main_spec.rb +88 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +50 -10
- data/spec/spec/example/example_group_methods_spec.rb +210 -160
- data/spec/spec/example/example_group_spec.rb +44 -52
- data/spec/spec/example/example_matcher_spec.rb +6 -23
- data/spec/spec/example/example_methods_spec.rb +176 -54
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/pending_module_spec.rb +2 -8
- data/spec/spec/example/shared_example_group_spec.rb +56 -80
- data/spec/spec/expectations/extensions/object_spec.rb +0 -50
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/be_spec.rb +62 -7
- data/spec/spec/matchers/description_generation_spec.rb +19 -0
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/handler_spec.rb +4 -43
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/raise_error_spec.rb +18 -0
- data/spec/spec/matchers/respond_to_spec.rb +71 -9
- data/spec/spec/matchers/throw_symbol_spec.rb +85 -43
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_spec.rb +5 -6
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +2 -2
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +18 -3
- data/spec/spec/mocks/stub_spec.rb +6 -0
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +14 -0
- data/spec/spec/runner/command_line_spec.rb +4 -4
- data/spec/spec/runner/configuration_spec.rb +301 -0
- data/spec/spec/runner/drb_command_line_spec.rb +4 -4
- data/spec/spec/runner/example_group_runner_spec.rb +33 -0
- data/spec/spec/runner/formatter/base_formatter_spec.rb +13 -102
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +9 -9
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +10 -10
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +39 -30
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +379 -0
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +379 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +14 -13
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +7 -17
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +18 -17
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +33 -30
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +373 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +373 -0
- data/spec/spec/runner/heckler_spec.rb +16 -9
- data/spec/spec/runner/option_parser_spec.rb +3 -18
- data/spec/spec/runner/options_spec.rb +27 -8
- data/spec/spec/runner/reporter_spec.rb +5 -5
- data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/spec/spec/runner/resources/utf8_encoded.rb +7 -0
- data/spec/spec/runner/spec_parser_spec.rb +85 -79
- data/spec/spec/spec_spec.rb +21 -0
- data/spec/spec_helper.rb +9 -1
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +119 -131
- data/examples/stories/adder.rb +0 -13
- data/examples/stories/addition +0 -34
- data/examples/stories/addition.rb +0 -9
- data/examples/stories/calculator.rb +0 -65
- data/examples/stories/game-of-life/.loadpath +0 -5
- data/examples/stories/game-of-life/README.txt +0 -21
- data/examples/stories/game-of-life/behaviour/everything.rb +0 -6
- data/examples/stories/game-of-life/behaviour/examples/examples.rb +0 -3
- data/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb +0 -35
- data/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb +0 -66
- data/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story +0 -17
- data/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story +0 -53
- data/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb +0 -52
- data/examples/stories/game-of-life/behaviour/stories/helper.rb +0 -6
- data/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb +0 -26
- data/examples/stories/game-of-life/behaviour/stories/steps.rb +0 -5
- data/examples/stories/game-of-life/behaviour/stories/stories.rb +0 -3
- data/examples/stories/game-of-life/behaviour/stories/stories.txt +0 -22
- data/examples/stories/game-of-life/life.rb +0 -3
- data/examples/stories/game-of-life/life/game.rb +0 -23
- data/examples/stories/game-of-life/life/grid.rb +0 -43
- data/examples/stories/helper.rb +0 -9
- data/examples/stories/steps/addition_steps.rb +0 -18
- data/lib/spec/adapters.rb +0 -1
- data/lib/spec/adapters/ruby_engine.rb +0 -26
- data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
- data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
- data/lib/spec/extensions.rb +0 -4
- data/lib/spec/extensions/class.rb +0 -24
- data/lib/spec/extensions/metaclass.rb +0 -7
- data/lib/spec/extensions/object.rb +0 -6
- data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
- data/spec/spec/example/configuration_spec.rb +0 -296
- data/spec/spec/example/example_runner_spec.rb +0 -194
- data/spec/spec/extensions/main_spec.rb +0 -71
- data/stories/all.rb +0 -5
- data/stories/configuration/before_blocks.story +0 -21
- data/stories/configuration/stories.rb +0 -7
- data/stories/example_groups/stories.rb +0 -7
- data/stories/helper.rb +0 -6
- data/stories/interop/stories.rb +0 -7
- data/stories/mock_framework_integration/stories.rb +0 -7
- data/stories/pending_stories/README +0 -3
- data/stories/resources/spec/before_blocks_example.rb +0 -32
- data/stories/resources/spec/spec_with_flexmock.rb +0 -18
- data/stories/resources/steps/running_rspec.rb +0 -50
- data/stories/resources/stories/failing_story.rb +0 -15
- data/stories/stories/multiline_steps.story +0 -23
- data/stories/stories/steps/multiline_steps.rb +0 -13
- data/stories/stories/stories.rb +0 -6
@@ -1,52 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), *%w[helper])
|
2
|
-
|
3
|
-
Story "I can create a cell",
|
4
|
-
%(As a game producer
|
5
|
-
I want to create a cell
|
6
|
-
So that I can show the grid to people), :steps_for => :life do
|
7
|
-
|
8
|
-
Scenario "nothing to see here" do
|
9
|
-
Given "a game with dimensions", 3, 3 do |rows,cols|
|
10
|
-
@game = Game.new(rows,cols)
|
11
|
-
end
|
12
|
-
|
13
|
-
Then "the grid should look like", %(
|
14
|
-
...
|
15
|
-
...
|
16
|
-
...
|
17
|
-
)
|
18
|
-
end
|
19
|
-
|
20
|
-
Scenario "all on its lonesome" do
|
21
|
-
Given "a game with dimensions", 2, 2
|
22
|
-
When "I create a cell at", 1, 1 do |row,col|
|
23
|
-
@game.create_at(row,col)
|
24
|
-
end
|
25
|
-
Then "the grid should look like", %(
|
26
|
-
..
|
27
|
-
.X
|
28
|
-
)
|
29
|
-
end
|
30
|
-
|
31
|
-
Scenario "the grid has three cells" do
|
32
|
-
Given "a game with dimensions", 3, 3
|
33
|
-
When "I create a cell at", 0, 0
|
34
|
-
When "I create a cell at", 0, 1
|
35
|
-
When "I create a cell at", 2, 2
|
36
|
-
Then "the grid should look like", %(
|
37
|
-
XX.
|
38
|
-
...
|
39
|
-
..X
|
40
|
-
)
|
41
|
-
end
|
42
|
-
|
43
|
-
Scenario "more cells more more" do
|
44
|
-
GivenScenario "the grid has three cells"
|
45
|
-
When "I create a cell at", 2, 0
|
46
|
-
Then "the grid should look like", %(
|
47
|
-
XX.
|
48
|
-
...
|
49
|
-
X.X
|
50
|
-
)
|
51
|
-
end
|
52
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), *%w[helper])
|
2
|
-
|
3
|
-
Story 'I can kill a cell',
|
4
|
-
%(As a game producer
|
5
|
-
I want to kill a cell
|
6
|
-
So that when I make a mistake I don't have to start again), :steps_for => :life do
|
7
|
-
|
8
|
-
Scenario "bang, you're dead" do
|
9
|
-
|
10
|
-
Given 'a game that looks like', %(
|
11
|
-
XX.
|
12
|
-
.X.
|
13
|
-
..X
|
14
|
-
) do |dots|
|
15
|
-
@game = Game.from_string dots
|
16
|
-
end
|
17
|
-
When 'I destroy the cell at', 0, 1 do |row,col|
|
18
|
-
@game.destroy_at(row,col)
|
19
|
-
end
|
20
|
-
Then 'the grid should look like', %(
|
21
|
-
X..
|
22
|
-
.X.
|
23
|
-
..X
|
24
|
-
)
|
25
|
-
end
|
26
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Story: Show the game field
|
2
|
-
As a game player
|
3
|
-
I want to see the field
|
4
|
-
so that I can observe the progress of the organisms
|
5
|
-
|
6
|
-
Scenario: an empty field
|
7
|
-
Given a new game starts
|
8
|
-
When the game displays the field
|
9
|
-
Then the field should be empty
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
StoryBuilder story = stories.createStory().called("a story")
|
16
|
-
.asA("person")
|
17
|
-
.iWant("to do something")
|
18
|
-
.soThat("I can rule the world");
|
19
|
-
story.addScenario().called("happy path").as()
|
20
|
-
.given("some context")
|
21
|
-
.when("some event happens")
|
22
|
-
.then("expect some outcome");
|
@@ -1,23 +0,0 @@
|
|
1
|
-
class Game
|
2
|
-
attr_accessor :grid
|
3
|
-
def initialize(rows,cols)
|
4
|
-
@grid = Grid.new(rows, cols)
|
5
|
-
end
|
6
|
-
|
7
|
-
def create_at(row,col)
|
8
|
-
@grid.create_at(row,col)
|
9
|
-
end
|
10
|
-
|
11
|
-
def destroy_at(row,col)
|
12
|
-
@grid.destroy_at(row, col)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.from_string(dots)
|
16
|
-
grid = Grid.from_string(dots)
|
17
|
-
game = new(grid.rows, grid.columns)
|
18
|
-
game.instance_eval do
|
19
|
-
@grid = grid
|
20
|
-
end
|
21
|
-
return game
|
22
|
-
end
|
23
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class Grid
|
2
|
-
|
3
|
-
attr_accessor :contents
|
4
|
-
|
5
|
-
def initialize(rows, cols)
|
6
|
-
@contents = []
|
7
|
-
rows.times do @contents << [0] * cols end
|
8
|
-
end
|
9
|
-
|
10
|
-
def rows
|
11
|
-
@contents.size
|
12
|
-
end
|
13
|
-
|
14
|
-
def columns
|
15
|
-
@contents[0].size
|
16
|
-
end
|
17
|
-
|
18
|
-
def ==(other)
|
19
|
-
self.contents == other.contents
|
20
|
-
end
|
21
|
-
|
22
|
-
def create_at(row,col)
|
23
|
-
@contents[row][col] = 1
|
24
|
-
end
|
25
|
-
|
26
|
-
def destroy_at(row,col)
|
27
|
-
@contents[row][col] = 0
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.from_string(str)
|
31
|
-
row_strings = str.split(' ')
|
32
|
-
grid = new(row_strings.size, row_strings[0].size)
|
33
|
-
|
34
|
-
row_strings.each_with_index do |row, row_index|
|
35
|
-
row_chars = row.split(//)
|
36
|
-
row_chars.each_with_index do |col_char, col_index|
|
37
|
-
grid.create_at(row_index, col_index) if col_char == 'X'
|
38
|
-
end
|
39
|
-
end
|
40
|
-
return grid
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/examples/stories/helper.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
|
2
|
-
require 'spec/story'
|
3
|
-
|
4
|
-
# won't have to do this once plain_text_story_runner is moved into the library
|
5
|
-
# require File.join(File.dirname(__FILE__), "plain_text_story_runner")
|
6
|
-
|
7
|
-
Dir[File.join(File.dirname(__FILE__), "steps/*.rb")].each do |file|
|
8
|
-
require file
|
9
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../helper")
|
2
|
-
|
3
|
-
# This creates steps for :addition
|
4
|
-
steps_for(:addition) do
|
5
|
-
Given("an addend of $addend") do |addend|
|
6
|
-
@adder ||= Adder.new
|
7
|
-
@adder << addend.to_i
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# This appends to them
|
12
|
-
steps_for(:addition) do
|
13
|
-
When("the addends are added") { @sum = @adder.sum }
|
14
|
-
end
|
15
|
-
|
16
|
-
steps_for(:more_addition) do
|
17
|
-
Then("the sum should be $sum") { |sum| @sum.should == sum.to_i }
|
18
|
-
end
|
data/lib/spec/adapters.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'spec/adapters/ruby_engine'
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec/adapters/ruby_engine/mri'
|
2
|
-
require 'spec/adapters/ruby_engine/rubinius'
|
3
|
-
|
4
|
-
module Spec
|
5
|
-
module Adapters
|
6
|
-
module RubyEngine
|
7
|
-
|
8
|
-
ENGINES = {
|
9
|
-
'mri' => MRI.new,
|
10
|
-
'rbx' => Rubinius.new
|
11
|
-
}
|
12
|
-
|
13
|
-
def self.engine
|
14
|
-
if Object.const_defined?('RUBY_ENGINE')
|
15
|
-
return Object.const_get('RUBY_ENGINE')
|
16
|
-
else
|
17
|
-
return 'mri'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.adapter
|
22
|
-
return ENGINES[engine]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/spec/extensions.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
class Class
|
2
|
-
# Creates a new subclass of self, with a name "under" our own name.
|
3
|
-
# Example:
|
4
|
-
#
|
5
|
-
# x = Foo::Bar.subclass('Zap'){}
|
6
|
-
# x.name # => Foo::Bar::Zap_1
|
7
|
-
# x.superclass.name # => Foo::Bar
|
8
|
-
def subclass(base_name, &body)
|
9
|
-
klass = Class.new(self)
|
10
|
-
class_name = "#{base_name}_#{class_count!}"
|
11
|
-
instance_eval do
|
12
|
-
const_set(class_name, klass)
|
13
|
-
end
|
14
|
-
klass.instance_eval(&body)
|
15
|
-
klass
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
def class_count!
|
20
|
-
@class_count ||= 0
|
21
|
-
@class_count += 1
|
22
|
-
@class_count
|
23
|
-
end
|
24
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe Spec::Adapters::RubyEngine do
|
2
|
-
it "should default to MRI" do
|
3
|
-
Spec::Adapters::RubyEngine.adapter.should be_an_instance_of(Spec::Adapters::RubyEngine::MRI)
|
4
|
-
end
|
5
|
-
|
6
|
-
it "should provide Rubinius for rbx" do
|
7
|
-
Spec::Adapters::RubyEngine.stub!(:engine).and_return('rbx')
|
8
|
-
Spec::Adapters::RubyEngine.adapter.should be_an_instance_of(Spec::Adapters::RubyEngine::Rubinius)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should try to find whatever is defined by the RUBY_ENGINE const" do
|
12
|
-
Object.stub!(:const_defined?).with('RUBY_ENGINE').and_return(true)
|
13
|
-
Object.stub!(:const_get).with('RUBY_ENGINE').and_return("xyz")
|
14
|
-
Spec::Adapters::RubyEngine.engine.should == "xyz"
|
15
|
-
end
|
16
|
-
end
|
@@ -1,296 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
-
|
3
|
-
module Spec
|
4
|
-
module Example
|
5
|
-
describe Configuration do
|
6
|
-
|
7
|
-
describe "#mock_with" do
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@config = Configuration.new
|
11
|
-
@example_group = mock("example_group")
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should default mock framework to rspec" do
|
15
|
-
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should set rspec mocking explicitly" do
|
19
|
-
@config.mock_with(:rspec)
|
20
|
-
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rspec$/
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should set mocha" do
|
24
|
-
@config.mock_with(:mocha)
|
25
|
-
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/mocha$/
|
26
|
-
end
|
27
|
-
|
28
|
-
it "should set flexmock" do
|
29
|
-
@config.mock_with(:flexmock)
|
30
|
-
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/flexmock$/
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should set rr" do
|
34
|
-
@config.mock_with(:rr)
|
35
|
-
@config.mock_framework.should =~ /\/plugins\/mock_frameworks\/rr$/
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should set an arbitrary adapter module" do
|
39
|
-
adapter = Module.new
|
40
|
-
@config.mock_with(adapter)
|
41
|
-
@config.mock_framework.should == adapter
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
with_sandboxed_config do
|
46
|
-
|
47
|
-
describe "#include" do
|
48
|
-
|
49
|
-
before(:each) do
|
50
|
-
@example_group_class = Class.new(ExampleGroup) {}
|
51
|
-
ExampleGroupFactory.register(:foobar, @example_group_class)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should include the submitted module in ExampleGroup subclasses" do
|
55
|
-
mod = Module.new
|
56
|
-
config.include mod
|
57
|
-
Class.new(@example_group_class).included_modules.should include(mod)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should scope modules to be included for a specific type" do
|
61
|
-
mod = Module.new
|
62
|
-
config.include mod, :type => :foobar
|
63
|
-
Class.new(@example_group_class).included_modules.should include(mod)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should not include modules in a type they are not intended for" do
|
67
|
-
mod = Module.new
|
68
|
-
@other_example_group_class = Class.new(ExampleGroup)
|
69
|
-
ExampleGroupFactory.register(:baz, @other_example_group_class)
|
70
|
-
|
71
|
-
config.include mod, :type => :foobar
|
72
|
-
|
73
|
-
Class.new(@other_example_group_class).included_modules.should_not include(mod)
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#extend" do
|
79
|
-
|
80
|
-
before(:each) do
|
81
|
-
@example_group_class = Class.new(ExampleGroup) {}
|
82
|
-
ExampleGroupFactory.register(:foobar, @example_group_class)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should extend all groups" do
|
86
|
-
mod = Module.new
|
87
|
-
ExampleGroup.should_receive(:extend).with(mod)
|
88
|
-
Spec::Runner.configuration.extend mod
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should extend specified groups" do
|
92
|
-
mod = Module.new
|
93
|
-
@example_group_class.should_receive(:extend).with(mod)
|
94
|
-
Spec::Runner.configuration.extend mod, :type => :foobar
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should not extend non-specified groups" do
|
98
|
-
@other_example_group_class = Class.new(ExampleGroup)
|
99
|
-
ExampleGroupFactory.register(:baz, @other_example_group_class)
|
100
|
-
|
101
|
-
mod = Module.new
|
102
|
-
@other_example_group_class.should_not_receive(:extend)
|
103
|
-
|
104
|
-
Spec::Runner.configuration.extend mod, :type => :foobar
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
describe Configuration do
|
111
|
-
|
112
|
-
before(:each) do
|
113
|
-
@special_example_group = Class.new(ExampleGroup).describe("special_example_group")
|
114
|
-
@special_child_example_group = Class.new(@special_example_group).describe("special_child_example_group")
|
115
|
-
@nonspecial_example_group = Class.new(ExampleGroup).describe("nonspecial_example_group")
|
116
|
-
ExampleGroupFactory.register(:special, @special_example_group)
|
117
|
-
ExampleGroupFactory.register(:special_child, @special_child_example_group)
|
118
|
-
ExampleGroupFactory.register(:non_special, @nonspecial_example_group)
|
119
|
-
@example_group = @special_child_example_group.describe "Special Example Group"
|
120
|
-
@unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group"
|
121
|
-
end
|
122
|
-
|
123
|
-
describe "#prepend_before" do
|
124
|
-
it "prepends the before block on all instances of the passed in type" do
|
125
|
-
order = []
|
126
|
-
config.prepend_before(:all) do
|
127
|
-
order << :prepend__before_all
|
128
|
-
end
|
129
|
-
config.prepend_before(:all, :type => :special) do
|
130
|
-
order << :special_prepend__before_all
|
131
|
-
end
|
132
|
-
config.prepend_before(:all, :type => :special_child) do
|
133
|
-
order << :special_child_prepend__before_all
|
134
|
-
end
|
135
|
-
config.prepend_before(:each) do
|
136
|
-
order << :prepend__before_each
|
137
|
-
end
|
138
|
-
config.prepend_before(:each, :type => :special) do
|
139
|
-
order << :special_prepend__before_each
|
140
|
-
end
|
141
|
-
config.prepend_before(:each, :type => :special_child) do
|
142
|
-
order << :special_child_prepend__before_each
|
143
|
-
end
|
144
|
-
config.prepend_before(:all, :type => :non_special) do
|
145
|
-
order << :special_prepend__before_all
|
146
|
-
end
|
147
|
-
config.prepend_before(:each, :type => :non_special) do
|
148
|
-
order << :special_prepend__before_each
|
149
|
-
end
|
150
|
-
@example_group.it "calls prepend_before" do
|
151
|
-
end
|
152
|
-
|
153
|
-
@example_group.run
|
154
|
-
order.should == [
|
155
|
-
:prepend__before_all,
|
156
|
-
:special_prepend__before_all,
|
157
|
-
:special_child_prepend__before_all,
|
158
|
-
:prepend__before_each,
|
159
|
-
:special_prepend__before_each,
|
160
|
-
:special_child_prepend__before_each
|
161
|
-
]
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe "#append_before" do
|
166
|
-
|
167
|
-
it "calls append_before on the type" do
|
168
|
-
order = []
|
169
|
-
config.append_before(:all) do
|
170
|
-
order << :append_before_all
|
171
|
-
end
|
172
|
-
config.append_before(:all, :type => :special) do
|
173
|
-
order << :special_append_before_all
|
174
|
-
end
|
175
|
-
config.append_before(:all, :type => :special_child) do
|
176
|
-
order << :special_child_append_before_all
|
177
|
-
end
|
178
|
-
config.append_before(:each) do
|
179
|
-
order << :append_before_each
|
180
|
-
end
|
181
|
-
config.append_before(:each, :type => :special) do
|
182
|
-
order << :special_append_before_each
|
183
|
-
end
|
184
|
-
config.append_before(:each, :type => :special_child) do
|
185
|
-
order << :special_child_append_before_each
|
186
|
-
end
|
187
|
-
config.append_before(:all, :type => :non_special) do
|
188
|
-
order << :special_append_before_all
|
189
|
-
end
|
190
|
-
config.append_before(:each, :type => :non_special) do
|
191
|
-
order << :special_append_before_each
|
192
|
-
end
|
193
|
-
@example_group.it "calls append_before" do
|
194
|
-
end
|
195
|
-
|
196
|
-
@example_group.run
|
197
|
-
order.should == [
|
198
|
-
:append_before_all,
|
199
|
-
:special_append_before_all,
|
200
|
-
:special_child_append_before_all,
|
201
|
-
:append_before_each,
|
202
|
-
:special_append_before_each,
|
203
|
-
:special_child_append_before_each
|
204
|
-
]
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "#prepend_after" do
|
209
|
-
|
210
|
-
it "prepends the after block on all instances of the passed in type" do
|
211
|
-
order = []
|
212
|
-
config.prepend_after(:all) do
|
213
|
-
order << :prepend__after_all
|
214
|
-
end
|
215
|
-
config.prepend_after(:all, :type => :special) do
|
216
|
-
order << :special_prepend__after_all
|
217
|
-
end
|
218
|
-
config.prepend_after(:all, :type => :special) do
|
219
|
-
order << :special_child_prepend__after_all
|
220
|
-
end
|
221
|
-
config.prepend_after(:each) do
|
222
|
-
order << :prepend__after_each
|
223
|
-
end
|
224
|
-
config.prepend_after(:each, :type => :special) do
|
225
|
-
order << :special_prepend__after_each
|
226
|
-
end
|
227
|
-
config.prepend_after(:each, :type => :special) do
|
228
|
-
order << :special_child_prepend__after_each
|
229
|
-
end
|
230
|
-
config.prepend_after(:all, :type => :non_special) do
|
231
|
-
order << :special_prepend__after_all
|
232
|
-
end
|
233
|
-
config.prepend_after(:each, :type => :non_special) do
|
234
|
-
order << :special_prepend__after_each
|
235
|
-
end
|
236
|
-
@example_group.it "calls prepend_after" do
|
237
|
-
end
|
238
|
-
|
239
|
-
@example_group.run
|
240
|
-
order.should == [
|
241
|
-
:special_child_prepend__after_each,
|
242
|
-
:special_prepend__after_each,
|
243
|
-
:prepend__after_each,
|
244
|
-
:special_child_prepend__after_all,
|
245
|
-
:special_prepend__after_all,
|
246
|
-
:prepend__after_all
|
247
|
-
]
|
248
|
-
end
|
249
|
-
end
|
250
|
-
|
251
|
-
describe "#append_after" do
|
252
|
-
|
253
|
-
it "calls append_after on the type" do
|
254
|
-
order = []
|
255
|
-
config.append_after(:all) do
|
256
|
-
order << :append__after_all
|
257
|
-
end
|
258
|
-
config.append_after(:all, :type => :special) do
|
259
|
-
order << :special_append__after_all
|
260
|
-
end
|
261
|
-
config.append_after(:all, :type => :special_child) do
|
262
|
-
order << :special_child_append__after_all
|
263
|
-
end
|
264
|
-
config.append_after(:each) do
|
265
|
-
order << :append__after_each
|
266
|
-
end
|
267
|
-
config.append_after(:each, :type => :special) do
|
268
|
-
order << :special_append__after_each
|
269
|
-
end
|
270
|
-
config.append_after(:each, :type => :special_child) do
|
271
|
-
order << :special_child_append__after_each
|
272
|
-
end
|
273
|
-
config.append_after(:all, :type => :non_special) do
|
274
|
-
order << :non_special_append_after_all
|
275
|
-
end
|
276
|
-
config.append_after(:each, :type => :non_special) do
|
277
|
-
order << :non_special_append_after_each
|
278
|
-
end
|
279
|
-
@example_group.it "calls append_after" do
|
280
|
-
end
|
281
|
-
|
282
|
-
@example_group.run
|
283
|
-
order.should == [
|
284
|
-
:special_child_append__after_each,
|
285
|
-
:special_append__after_each,
|
286
|
-
:append__after_each,
|
287
|
-
:special_child_append__after_all,
|
288
|
-
:special_append__after_all,
|
289
|
-
:append__after_all
|
290
|
-
]
|
291
|
-
end
|
292
|
-
end
|
293
|
-
end
|
294
|
-
end
|
295
|
-
end
|
296
|
-
end
|