spec/acceptance/gatling_acceptance_spec.rb in gatling-1.0.8 vs spec/acceptance/gatling_acceptance_spec.rb in gatling-1.0.9
- old
+ new
@@ -6,16 +6,16 @@
before(:all) do
@spec_support_root = spec_support_root
end
before(:each) do
- @ref_path = Gatling::Configuration.reference_image_path = File.join(spec_support_root, 'ref_path')
+ @ref_path = Gatling.reference_image_path = File.join(spec_support_root, 'ref_path')
end
after(:each) do
remove_refs(@ref_path)
- Gatling::Configuration.trainer_toggle = false
+ config_clean_up
end
describe 'Gatling, when no reference image exists' do
it "will notify that no reference image exists and create a candidate image" do
@@ -40,29 +40,41 @@
black_element = element_for_spec('#black')
Gatling.matches?("black.png", black_element).should be_true
end
- it 'will return false, creates new diff and candidate images if the images are different' do
- red_element = element_for_spec('#red')
- expected_error = "element did not match #{"black.png"}. " +
- "A diff image: #{"black.png"} was created in #{@ref_path}/diff/#{"black.png"}. " +
- "A new reference #{@ref_path}/candidate/#{"black.png"} can be used to fix the test"
+ describe 'between different images of the same size' do
- expect {Gatling.matches?("black.png", red_element)}.should raise_error(RuntimeError, expected_error)
+ it 'will return false, creates new diff and candidate images' do
+ red_element = element_for_spec('#red')
+ expected_error = "element did not match #{"black.png"}. " +
+ "A diff image: #{"black.png"} was created in #{@ref_path}/diff/#{"black.png"} " +
+ "A new reference #{@ref_path}/candidate/#{"black.png"} can be used to fix the test"
- File.exists?(File.join(@ref_path,'diff', "black.png")).should be_true
- File.exists?(File.join(@ref_path,'candidate', "black.png")).should be_true
+ expect {Gatling.matches?("black.png", red_element)}.should raise_error(RuntimeError, expected_error)
+
+ File.exists?(File.join(@ref_path,'diff', "black.png")).should be_true
+ File.exists?(File.join(@ref_path,'candidate', "black.png")).should be_true
+ end
+
end
- # it 'will try to match a specified amount of time before failing' do
- # red_element = element_for_spec('#red')
- # Gatling.should_receive(:matches?).and_return(false)
- # Gatling.should_receive(:try_until_match)
- # Gatling.matches?("black.png", red_element)
- # end
+ describe 'between images of the different size' do
+ it 'will return false, creates new diff and candidate images' do
+ red_element = element_for_spec('#differentSize')
+ expected_error = "element did not match #{"black.png"}. " +
+ "A diff image: #{"black.png"} was created in #{@ref_path}/diff/#{"black.png"} " +
+ "A new reference #{@ref_path}/candidate/#{"black.png"} can be used to fix the test"
+
+ expect {Gatling.matches?("black.png", red_element)}.should raise_error(RuntimeError, expected_error)
+
+ File.exists?(File.join(@ref_path,'diff', "black.png")).should be_true
+ File.exists?(File.join(@ref_path,'candidate', "black.png")).should be_true
+ end
+
+ end
end
describe 'Gatling trainer toggle' do
it 'will save a reference file if no reference file already exists' do
@@ -77,11 +89,11 @@
end
it 'will warn if a reference already exists and not overwrite it' do
create_square_image(@ref_path, 'black')
Gatling::Configuration.trainer_toggle = true
- expected_message = " already exists. reference image was not overwritten. " +
+ expected_message = "#{File.join(@ref_path,"black.png")} already exists. reference image was not overwritten. " +
"please delete the old file to update using trainer"
black_element = element_for_spec
reference_file_ctime = File.ctime(File.join(@ref_path,"black.png"))
$stdout.should_receive(:puts).with expected_message
@@ -89,6 +101,18 @@
sleep(1)
reference_file_ctime.eql?(File.ctime(File.join(@ref_path, "black.png"))).should be_true
end
end
+
+ describe 'Gatling browser folders' do
+
+ it 'should set image path according to the driver\'s browser' do
+ Gatling.browser_folders = true
+ Gatling.reference_image_path = '/some/random/path'
+ Gatling::Configuration.reference_image_path.should == '/some/random/path/firefox'
+ Gatling.browser_folders = false
+ end
+ end
+
+
end