Module: Rasta::Fixture::BaseFixture
- Included in:
- RastaFixture
- Defined in:
- lib/rasta/fixture/base_fixture.rb
Defined Under Namespace
Classes: Metrics
Instance Method Summary collapse
-
#create_rspec_test(args) ⇒ Object
This is the guts of the rspec test you want to call so for example something like .
-
#current_failure_count ⇒ Object
Allow access to the current failure count from RSpec which will let us change the tab color based on the test results.
-
#generate_rspec_tests ⇒ Object
Iterate over spreadsheet cells, create the test fixtures and call your test.
- #initialize_run(sheet) ⇒ Object
-
#run ⇒ Object
Called by fixture.rb on each worksheet.
-
#run_rspec_test ⇒ Object
Call into rspec to run the current set of tests and then remove the example from the group which if we dont will run test 1 then test 1,2 then test 1,2,3 and we’ll get duplicate test results accordingly.
-
#select_output_cell(c) ⇒ Object
This is how the fixture notifies the rspec reporter which spreadsheet cell to dump the results into.
-
#tab_extension=(x) ⇒ Object
Store any extention in the tab name.
-
#teardown_tests ⇒ Object
This is called after all testcases are run for the worksheet.
Instance Method Details
#create_rspec_test(args) ⇒ Object
This is the guts of the rspec test you want to call so for example something like
describe ‘test’ do
before(:all) do
end
it "testcase 1" do
end
it "testcase 2" do
end
... etc ...
after(:all) do
end
end
68 69 |
# File 'lib/rasta/fixture/base_fixture.rb', line 68 def create_rspec_test(args) end |
#current_failure_count ⇒ Object
Allow access to the current failure count from RSpec which will let us change the tab color based on the test results
33 34 35 |
# File 'lib/rasta/fixture/base_fixture.rb', line 33 def current_failure_count Spec::Runner..reporter.failure_count end |
#generate_rspec_tests ⇒ Object
Iterate over spreadsheet cells, create the test fixtures and call your test. Generally you will need to iterate over the spreadsheet cells and once you have the information you need to actually run the rspec test you should use:
select_output_cell(cell)
This tells the reporter which spreadsheet
cell should get the results
create_rspec_test(test_fixture, cell)
This is a method you create which will create
rspec testcase(s) based on the inputs
run_rspec_test
This will run the test set up by create_test
51 52 |
# File 'lib/rasta/fixture/base_fixture.rb', line 51 def generate_rspec_tests end |
#initialize_run(sheet) ⇒ Object
5 6 7 8 |
# File 'lib/rasta/fixture/base_fixture.rb', line 5 def initialize_run(sheet) @sheet = sheet @metrics = Metrics.new end |
#run ⇒ Object
Called by fixture.rb on each worksheet
11 12 13 14 |
# File 'lib/rasta/fixture/base_fixture.rb', line 11 def run generate_rspec_tests teardown_tests end |
#run_rspec_test ⇒ Object
Call into rspec to run the current set of tests and then remove the example from the group which if we dont will run test 1 then test 1,2 then test 1,2,3 and we’ll get duplicate test results accordingly
20 21 22 23 |
# File 'lib/rasta/fixture/base_fixture.rb', line 20 def run_rspec_test Spec::Runner..run_examples Spec::Runner..remove_example_group(Spec::Runner..example_groups[0]) end |
#select_output_cell(c) ⇒ Object
This is how the fixture notifies the rspec reporter which spreadsheet cell to dump the results into
73 74 75 |
# File 'lib/rasta/fixture/base_fixture.rb', line 73 def select_output_cell(c) Spec::Runner..reporter.set_current_spreadsheet_cell = c end |
#tab_extension=(x) ⇒ Object
Store any extention in the tab name. This can be used to pass additional information to the fixture
132 133 134 |
# File 'lib/rasta/fixture/base_fixture.rb', line 132 def tab_extension=(x) @tab_extension = x end |
#teardown_tests ⇒ Object
This is called after all testcases are run for the worksheet.
27 28 29 |
# File 'lib/rasta/fixture/base_fixture.rb', line 27 def teardown_tests @sheet.select_home_cell end |